angular.module('mamApp').factory('RoleManager', ['$http', 'api', 'paramsManager', function ($http, api, paramsManager) {
    var RoleManager = {

        /**
         * 角色列表
         * @param params
         * @returns
         */

        roleList: function (params,query) {
            return $http.get(api+'/admin/roles/roleList/'+paramsManager.params(params)+paramsManager.query(query)).then(function (result) {
                return result;
            });
        },
        /**
         * 角色列表（id,name）
         * @param params
         * @returns
         */

        roleListSimple: function (params) {
            return $http.get(api+'/admin/roles/roleList').then(function (result) {
                return result;
            });
        },
        /**
         * 角色创建
         * @param params
         * @returns
         */

        roleCreate: function (params) {
            return $http.post(api+'/admin/roles/role',params).then(function (result) {
                return result;
            });
        },
        /**
         * 角色删除
         * @param params
         * @returns
         */

        roleDelete: function (roleId) {
            return $http.delete(api+'/admin/roles/role/'+roleId).then(function (result) {
                return result;
            });
        },
        /**
         * 角色详情
         * @param params
         * @returns
         */

        roleDetail: function (roleId) {
            return $http.get(api+'/admin/roles/role/'+roleId).then(function (result) {
                return result;
            });
        },
        /**
         * 角色修改
         * @param params
         * @return
         */

        roleEdit: function (params) {
            return $http.put(api+'/admin/roles/role',params).then(function (result) {
                return result;
            });
        },
        /**
         * 获取权限中内容中心的列表
         */
        roleChannelList:function () {
            return $http.get(api+'/admin/roles/role/channelList').then(function (result) {
                return result;
            });
        }

    };

    return RoleManager;
}]);

